import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'
// 修改密码
import changePassword from '@/views/layout/components/changePassword/changePassword'
// AppMain
import AppMain from '@/views/layout/components/AppMain'
// 项目管理
import projects from '@/components/projects/index'
// 项目详情
import project_detail from '@/components/projects/project_detail'
// 添加项目
import add_projects from '@/components/projects/add_projects'
// 分类管理
import class_management from '@/components/category/index'
// 医院管理
import hospital from '@/components/hospital/index'
// 广告位管理
import adv from '@/components/adv/index'
// 用户管理
import users from '@/components/users/index'
// 用户详情
import user_detail from '@/components/users/user_detail'
// 拼团管理
import groups from '@/components/groups/index'
// 拼团详情
import group_detail from '@/components/groups/group_detail'
// 拼团设置
import group_setting from '@/components/groups/group_setting'
// 订单管理
import orders from '@/views/orders/index'
// 订单详情
import order_detail from '@/views/orders/order_detail'
// 会员开通订单信息记录
import user_order from '@/views/orders/user_order'
// 素材管理
import material from '@/components/material/index'
// 财务回款
import finance_refund_money from '@/views/finance/finance_refund_money'
// 财务回款
import picture_detail from '@/views/finance/picture_detail'
// 消费凭证详情
import cash_list from '@/views/finance/cash_list'
// 权限管理
// 角色列表
import role from '@/components/limits/role/role'
// 添加角色
import add_role from '@/components/limits/role/add_role'

// 成员管理
import member from '@/components/limits/member/member'
// 添加成员
import add_member from '@/components/limits/member/add_member'

import homePage from '@/views/index/homePage'

/** note: sub-menu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']    will control the page roles (you can set multiple roles)
    title: 'title'               the name show in sub-menu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if true, the page will no be cached(default is false)
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
    affix: true                  if true, the tag will affix in the tags-view
  }
**/
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    hidden: true,
    children: [
    ]
  }
  /*   //  项目管理
      {
          path: '/',
          component: Layout,
          redirect: '/',
          children: [
              {
                  path: '/',
                  component: projects,
                  name: '/',
                  meta: { title: '项目管理', icon: 'xiangmu', affix: true },
                  noCache: true
              },
              {
                  path: '/project_detail',
                  component: project_detail,
                  name: '/project_detail',
                  meta: { title: '项目详情', icon: 'xiangmu', affix: true },
                  noCache: true,
                  hidden: true,
                  breadcrumb: false
              },
              {
                  path: '/add_projects',
                  component: add_projects,
                  name: '/add_projects',
                  meta: { title: '添加项目', icon: 'xiangmu', affix: true },
                  noCache: true,
                  hidden: true,
                  breadcrumb: false
              }

          ]
      },
      // 分类管理
      {
          path: '/class_management',
          component: Layout,
          redirect: '/class_management',
          children: [
              {
                  path: 'class_management',
                  component: class_management,
                  name: 'class_management',
                  meta: { title: '分类管理', icon: 'fenlei', affix: true },
                  noCache: true
              }
          ]
      },
      // 医院管理
      {
          path: '/hospital',
          component: Layout,
          redirect: '/hospital',
          children: [
              {
                  path: '/hospital',
                  component: hospital,
                  name: 'hospital',
                  meta: { title: '医院管理', icon: 'yiyuan' },
                  noCache: true
              }
          ]
      },
      // 广告位管理
      {
          path: '/adv',
          component: Layout,
          redirect: '/adv',
          children: [
              {
                  path: '/adv',
                  component: adv,
                  name: 'adv',
                  meta: { title: '广告位管理', icon: 'guanggaoguanli' },
                  noCache: true
              }
          ]
      },
      // 用户管理
      {
          path: '/users',
          component: Layout,
          redirect: '/users',
          children: [
              {
                  path: '/users',
                  component: users,
                  name: 'users',
                  meta: { title: '用户管理', icon: 'peoples' },
                  noCache: true
              },
              {
                  path: '/user_detail',
                  component: user_detail,
                  name: 'user_detail',
                  meta: { title: '用户详情', icon: 'xiangmu', affix: true },
                  noCache: true,
                  hidden: true,
                  breadcrumb: false
              }

          ]
      },
      // 拼团管理
      {
          path: '/groups',
          component: Layout,
          redirect: '/groups',
          meta: {
              title: '拼团管理',
              icon: 'pintuanguanli'
          },
          children: [
              {
                  path: '/groups',
                  component: groups,
                  name: 'groups',
                  meta: { title: '拼团列表' },
                  noCache: true
              },
              {
                  path: '/group_setting',
                  component: group_setting,
                  name: 'group_setting',
                  meta: { title: '拼团设置' },
                  noCache: true
              },
              {
                  path: '/group_detail',
                  component: group_detail,
                  name: '/group_detail',
                  meta: { title: '拼团详情', icon: 'xiangmu', affix: true },
                  noCache: true,
                  hidden: true,
                  breadcrumb: false

              }

          ]
      },
      // 订单管理
      {
          path: '/orders',
          component: Layout,
          redirect: '/orders',
          meta: {
              title: '订单管理',
              icon: 'dingdan'
          },
          children: [
              {
                  path: '/orders',
                  component: orders,
                  name: '/orders',
                  meta: { title: '订单列表', icon: 'dingdan' },
                  noCache: true
              },
              {
                  path: '/user_order',
                  component: user_order,
                  name: '/user_order',
                  meta: { title: '会员开通订单信息记录', icon: 'dingdan' },
                  hidden: true,
                  noCache: true,
                  breadcrumb: false
              },
              {
                  path: '/order_detail',
                  component: order_detail,
                  name: '/order_detail',
                  meta: { title: '订单详情', icon: 'xiangmu', affix: true },
                  noCache: true,
                  hidden: true,
                  breadcrumb: false
              }
          ]
      },
      // 素材管理
      {
          path: '/material',
          component: Layout,
          redirect: '/material',
          children: [
              {
                  path: 'material',
                  component: material,
                  name: 'material',
                  meta: { title: '素材管理', icon: 'sucai' },
                  noCache: true
              }
          ]
      },
      // 财务管理
      {
          path: '/finance_refund_money',
          component: Layout,
          redirect: '/finance_refund_money',
          meta: {
              title: '财务管理',
              icon: 'pintuanguanli'
          },
          children: [
              {
                  path: 'finance_refund_money',
                  component: finance_refund_money,
                  name: 'finance_refund_money',
                  meta: { title: '财务回款', noCache: true }
              },
              {
                  path: 'cash_list',
                  component: cash_list,
                  name: 'cash_list',
                  meta: { title: '提现列表', noCache: true }
              },
              {
                  path: '/picture_detail',
                  component: picture_detail,
                  name: '/picture_detail',
                  meta: { title: '消费凭证详情', icon: 'xiangmu', affix: true },
                  noCache: true,
                  hidden: true,
                  breadcrumb: false
              }
          ]
      },
      // 权限管理
      {
          path: '/role',
          component: Layout,
          redirect: '/role',
          meta: {
              title: '权限管理', icon: 'quanxian'
          },
          children: [
              {
                  path: '/role',
                  component: role,
                  name: 'role',
                  meta: { title: '角色管理', noCache: true }
              },
              {
                  path: '/add_role',
                  component: add_role,
                  name: 'add_role',
                  meta: { title: '添加角色', noCache: true },
                  hidden: true,
                  breadcrumb: false
              },
              {
                  path: '/member',
                  component: member,
                  name: 'member',
                  meta: { title: '成员管理', noCache: true }
              },
              {
                  path: '/add_member',
                  component: add_member,
                  name: 'add_member',
                  meta: { title: '添加成员', noCache: true },
                  hidden: true,
                  breadcrumb: false
              }
          ]
      }
   */
]

export default new Router({
  // mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

/**
 * 后端返回的路由component 对应表
 */
import route from "./RoutsCollection"
import otherRoute from './ann'
export const routerMap = {
    ...route,
  ...otherRoute,
  Layout: () => import('@/views/layout/Layout'),

  AppMain: () => import('@/views/layout/components/AppMain'),

  projects: () => import('@/components/projects/index'),

  goods: () => import('@/components/goods/index'),

  talent: () => import('@/components/talent/index'),

  faq: () => import('@/components/faq/index'),

  ad_learning: () => import('@/components/ad_learning/index'),

  project_detail: () => import('@/components/projects/project_detail'),

  add_projects: () => import('@/components/projects/add_projects'),

  class_management: () => import('@/components/category/index'),

  hospital: () => import('@/components/hospital/index'),

  adv: () => import('@/components/adv/index'),

  vip_slideshow: () => import('@/components/vip_slideshow/index'),

  slideshow: () => import('@/components/slideshow/index'),

  fresh_news: () => import('@/components/fresh/index'),

  marketing: () => import('@/components/marketing/index'),

  users: () => import('@/components/users/index'),

  vip_setting: () => import('@/components/vip_setting/index'),

  user_detail: () => import('@/components/users/user_detail'),

  groups: () => import('@/components/groups/index'),

  group_setting: () => import('@/components/groups/group_setting'),

  group_detail: () => import('@/components/groups/group_detail'),

  orders: () => import('@/views/orders/index'),

  user_order: () => import('@/views/orders/user_order'),

  order_detail: () => import('@/views/orders/order_detail'),

  material: () => import('@/components/material/index'),

  finance_refund_money: () => import('@/views/finance/finance_refund_money'),

  cash_list: () => import('@/views/finance/cash_list'),

  picture_detail: () => import('@/views/finance/picture_detail'),

  role: () => import('@/components/limits/role/role'),

  add_role: () => import('@/components/limits/role/add_role'),

  member: () => import('@/components/limits/member/member'),

  add_member: () => import('@/components/limits/member/add_member')
}

export const asyncRoutes = [

]
